var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = cc._decorator,
    s = r.ccclass,
    c = r.property,
    p =
        (r.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.startColor = cc.Color.WHITE;
                e.endColor = cc.Color.WHITE;
                e._angle = 0;
                e._maxAngle = 360;
                e.dian_Line = {};
                e.dian_P = {0: 1, 1: 0, 2: 0, 3: 0};
                return e;
            }
            Object.defineProperty(e.prototype, "upView", {
                get: function () {
                    return !1;
                },
                set: function () {
                    this._updateColors();
                },
                enumerable: !1,
                configurable: !0
            });
            Object.defineProperty(e.prototype, "angle1", {
                get: function () {
                    return this._angle;
                },
                set: function (t) {
                    this._angle = (t + this._maxAngle) % this._maxAngle;
                    this._updateColors();
                },
                enumerable: !1,
                configurable: !0
            });
            e.prototype.onEnable = function () {
                cc.director.once(cc.Director.EVENT_AFTER_DRAW, this._updateColors, this);
                this._updateColors();
                this.upSetColor();
            };
            e.prototype.onDisable = function () {
                cc.director.off(cc.Director.EVENT_AFTER_DRAW, this._updateColors, this);
                this.node._renderFlag |= cc.RenderFlow.FLAG_COLOR;
            };
            e.prototype.upSetColor = function () {
                var t = this;
                this.schedule(function () {
                    t._updateColors();
                }, 0.1);
            };
            e.prototype._updateColors = function () {
                var t = this.getComponent(cc.RenderComponent);
                if (t) {
                    var e = t._assembler;
                    if (e instanceof cc.Assembler2D) {
                        var o = e._renderData.uintVDatas[0];
                        if (o)
                            for (
                                var a = this.node.color,
                                    i = e.floatsPerVert,
                                    n = e.colorOffset,
                                    r = 0,
                                    s = this.getColors(o.length),
                                    c = n,
                                    p = o.length;
                                c < p;
                                c += i
                            )
                                o[c] = (s[r++] || a)._val;
                    }
                }
            };
            e.prototype.getColors = function (t) {
                t = Math.floor(t / 20);
                var e = this.getc(t / 20);
                if (1 == t) return e;
                var o = [],
                    a = cc.Color.WHITE;
                o.push(e[0]);
                o.push(e[1]);
                o.push(e[2]);
                cc.Color.lerp(a, e[1], e[2], 0.5);
                for (var i = 0; i < t - 1; i++) for (var n = 0; n < 4; n++) o.push(a);
                o.push(e[3]);
                return o;
            };
            e.prototype.getc = function () {
                this.upPro();
                var t = [],
                    e = cc.Color.WHITE;
                cc.Color.lerp(e, this.startColor, this.endColor, 0);
                for (var o = 0; o < 4; o++) {
                    this.dian_Line[o] = cc.color(e.r, e.g, e.b);
                    cc.Color.lerp(this.dian_Line[o], e, this.endColor, this.dian_P[o] || 0);
                    t.push(this.dian_Line[o]);
                }
                return t;
            };
            e.prototype.upPro = function () {
                var t = this.angle1 / 180,
                    e = Math.floor(t);
                this.dian_P[(e + 2) % 4] = 1;
                this.dian_P[e] = t - e;
                this.dian_P[(e + 1) % 4] = 1 - this.dian_P[e];
                this.dian_P[(e + 4 - 1) % 4] = this.dian_P[(e + 1) % 4];
            };
            n([c({displayName: "开始色"})], e.prototype, "startColor", void 0);
            n([c({displayName: "设置色"})], e.prototype, "endColor", void 0);
            n([c({displayName: "刷新"})], e.prototype, "upView", null);
            n([c], e.prototype, "_angle", void 0);
            n([c({type: cc.Integer, displayName: "设置角度", tooltip: "只允许0~359"})], e.prototype, "angle1", null);
            return n([s], e);
        })(cc.Component));
o.default = p;
